<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 300px;
            height: 300px;
            margin: 100px auto;
            background: pink;
        }
    </style>
</head>

<body>
    <div></div>
    <script>
        const box = document.querySelector('div')
        box.addEventListener('mousemove', (e) => {
            /* console.log(`x=${e.pageX}, y=${e.pageY}`);
            console.log(`l=${box.offsetLeft}, t=${box.offsetTop}`); */
            box.innerHTML = `x=${e.pageX - box.offsetLeft}, y=${e.pageY - box.offsetTop}`
        })
        box.addEventListener('selectstart', function(e) {
            e.preventDefault();
        })
        box.style.cursor = 'default'
    </script>
</body>

</html>